package cn.shopifymall.studying.classloader;

/**
 * 自定义类加载器，加载jar包
 *
 * @Author 孤风雪影
 * @Email gitee.com/efairy520
 * @Date 2025/1/16 10:23
 * @Version 1.0
 */
public class OADemo03 {
    public static void main(String[] args) throws Exception {
        Double money = 2000.0;
        SalaryJarLoader salaryJarLoader = new SalaryJarLoader("D:\\swift-kit.jar");
        while (true) {
            Double salary = calSalary(money, salaryJarLoader);
            System.out.println("实际到手的工资 = " + salary);
            Thread.sleep(1000);
        }
    }
    private static Double calSalary(Double salary, ClassLoader classLoader) throws Exception {
        Class<?> clazz = classLoader.loadClass("cn.shopifymall.studying.kit.SalaryCaler");
        Object object = clazz.newInstance();
        return (Double) clazz.getMethod("cal", Double.class).invoke(object, salary);
    }
}
